fix(converter): parse tool_use.input JSON string into object#13
Open
digachoy wants to merge 1 commit intonielspeter:mainfrom
Open
fix(converter): parse tool_use.input JSON string into object#13digachoy wants to merge 1 commit intonielspeter:mainfrom
digachoy wants to merge 1 commit intonielspeter:mainfrom
Conversation
Anthropic's Messages API spec requires content blocks of type
'tool_use' to carry 'input' as a JSON object. OpenAI-compat upstreams
return function arguments as a JSON-encoded string, and we were
forwarding that string verbatim, which breaks downstream Anthropic
SDKs (including Claude Code CLI) that expect an object.
Parse the arguments string into interface{} so the final JSON-encoding
emits a proper object; fall back to an empty object when arguments are
missing, and leave the raw string only when it is not valid JSON.
Extend TestConvertResponse to assert Input is a map[string]interface{}
and add coverage for the empty-arguments case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Anthropic's Messages API spec requires content blocks of type 'tool_use' to carry 'input' as a JSON object. OpenAI-compat upstreams return function arguments as a JSON-encoded string, and we were forwarding that string verbatim, which breaks downstream Anthropic SDKs (including Claude Code CLI) that expect an object.
Parse the arguments string into interface{} so the final JSON-encoding emits a proper object; fall back to an empty object when arguments are missing, and leave the raw string only when it is not valid JSON.
Extend TestConvertResponse to assert Input is a map[string]interface{} and add coverage for the empty-arguments case.